import { reqGetCategoryListData, reqGetBannerListData, reqGetFloorListData } from '@/api';
const state = {
  // 三级导航数据
  categoryList: [],
  // 轮播数据
  bannerList: [],
  // 楼层数据
  floorList: []
};
const actions = {
  // 获取三级导航数据
  async getCategoryListDataActions(context) {
    const result = await reqGetCategoryListData();
    if (result.code === 200) {
      context.commit('SAVE_CATEGORY_LIST_DATA', result.data);
    } else {
      console.log(result.message);
    }
  },

  // 获取轮播数据
  async getBannerListDataActions(context) {
    const result = await reqGetBannerListData();
    if (result.code === 200) {
      context.commit('SAVE_BANNER_LIST_DATA', result.data);
    } else {
      console.log(result.message);
    }
  },

  // 获取楼层数据
  async getFloorListDataActions(context) {
    const result = await reqGetFloorListData();
    if (result.code === 200) {
      context.commit('SAVE_FLOOR_LIST_DATA', result.data);
    } else {
      console.log(result.message);
    }
  }
};
const mutations = {
  // 存储三级导航数据
  SAVE_CATEGORY_LIST_DATA(state, categoryList) {
    state.categoryList = categoryList;
  },

  // 存储轮播数据
  SAVE_BANNER_LIST_DATA(state, bannerList) {
    state.bannerList = bannerList;
  },

  // 存储楼层数据
  SAVE_FLOOR_LIST_DATA(state, floorList) {
    // console.log('楼层', floorList);
    state.floorList = floorList;
  }
};
const getters = {};

export default {
  namespaced: true, // 开启命名空间，以便区分是哪个模块的数据
  state,
  actions,
  mutations,
  getters
};
